<?php

namespace App\Listener;

use App\Events\AgentYuyue as yuyue;
use App\Service\MessageService;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class AgentYuyue implements ShouldQueue
{ //发送短信
    protected $messageService;
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct(MessageService $messageService)
    {
        $this->messageService=$messageService;
    }

    /**
     * Handle the event.
     *
     * @param  AgentYuyue  $event
     * @return void
     */
    public function handle(yuyue $event)
    {

        $agent=\App\model\agent\Agent::find($event->agentYuyue->agent_id);

        $workshop=\App\model\Workshop::find($event->agentYuyue->workshop_id);
        $this->messageService->sendMessage($agent->mobile,$event->agentYuyue->name,$event->agentYuyue->time,$workshop->code);
    }
}
